package com.accountbooks.justin;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import android.support.v4.app.Fragment;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class TotalFragment extends Fragment {
	private DBManager dbManager ;
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		dbManager = new DBManager(activity);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		//ListView listView = getListView();
		Calendar calendar = Calendar.getInstance();

		
		List<AccountType> accountTypes = new ArrayList<AccountType>();
		
		accountTypes.add(new AccountType(0, "Traffic", calendar.getTime().toGMTString(), calendar.getTime().toString()));
		accountTypes.add(new AccountType(0, "Food", calendar.getTime().toGMTString(), calendar.getTime().toString()));
		accountTypes.add(new AccountType(0, "Purchase", calendar.getTime().toGMTString(), calendar.getTime().toString()));
		
		
		dbManager.addAccountType(accountTypes);
		accountTypes.clear();
		accountTypes = dbManager.getAllAccountType();
		
		for(AccountType item : accountTypes) {
			Log.e("Value", item.getTypeName());
			Log.e("Value", item.getCreatedOn());
			Log.e("Value", String.valueOf(item.getTypeID()));
		}
		
		dbManager.closeDB();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// onCreateView 必须返回一个View 我们可以使用inflater.inflate并传入布局，inflate会根据布局产生一个View
		//return inflater.inflate(R.layout.total_fragment, container, false);
		return super.onCreateView(inflater, container, savedInstanceState);
	}

}
